import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import {Form, Input, List, Modal, Select} from 'antd'
import {t, Trans} from "@lingui/macro"
import api from '../../../services/api'
const {createUserAvatar, createAdminContentImage} = api

const { Option } = Select;
const FormItem = Form.Item
//时间格式化
const datetimeFormat = "YYYY-MM-DD HH:mm:ss"
const dateFormat = "YYYY-MM-DD"
const formItemLayout = {
  labelCol: {
    span: 6,
  },
  wrapperCol: {
    span: 14,
  },
}


function formatTime(date) {
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let hours = date.getHours();
  let minutes = date.getMinutes();
  let seconds = date.getSeconds();

  month = month < 10 ? "0" + month : month;
  day = day < 10 ? "0" + day : day;
  hours = hours < 10 ? "0" + hours : hours;
  minutes = minutes < 10 ? "0" + minutes : minutes;
  seconds = seconds < 10 ? "0" + seconds : seconds;

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

class TemporalTableColDataModal extends PureComponent {
  formRef = React.createRef()

  state = {
    value: [],
    loading: false, //上传 loading
  };


  handleOk = () => {
    const { item = {}, onOk } = this.props
    onOk();
  }

  render() {
    const { item = {}, onOk, form,options,trees,data, ...modalProps } = this.props
    const {list = []} = data;
    console.log(this.props)
    //初始化时间处理
    return (

      <Modal {...modalProps} onOk={this.handleOk} width={370}>
        <List>
          {list.map(item=>{
            return <List.Item><pre>[{(new Date(item.time)).toLocaleDateString()} {(new Date(item.time)).toLocaleTimeString()}]     {item.val}</pre></List.Item>
          })}
        </List>

      </Modal>
    )
  }
}

TemporalTableColDataModal.propTypes = {
  type: PropTypes.string,
  item: PropTypes.object,
  onOk: PropTypes.func,
}

export default TemporalTableColDataModal
